package com.kfm.service;

import com.kfm.dao.UserDao;
import com.kfm.model.KfmUser;

import java.sql.SQLException;

/**
 * user用户的业务层
 */
public class UerService {

    UserDao userDao;
    public UerService() throws Exception {
        userDao = new UserDao();
    }

    /**
     * 处理登录
     * @param username 用户输入的用户名
     * @param password 用户输入的密码
     * @return 如果登录成功返回用户对象 失败返回null
     */
    public KfmUser login(String username, String password) {
        if (username == null || password == null) {
            return null;
        }
        try {
            return userDao.selectByUsernameAndPassword(username, password);
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }
}
